package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Store;
import com.woniuxy.dudugua.mapper.ProductMapper;
import com.woniuxy.dudugua.mapper.StoreMapper;
import com.woniuxy.dudugua.service.StoreService;
import com.woniuxy.dudugua.util.view.StoreNavBar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StoreServiceImpl implements StoreService {

    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<Store> getAll() {
        List<Store> stores = storeMapper.selectByExample(null);
        return stores;
    }

    @Override
    public Store selectById(int id) {
        Store store = storeMapper.selectByPrimaryKey(id);
        return store;
    }

    @Override
    public List<StoreNavBar> selectNavbarById(int id) {
        List<StoreNavBar> storeNavBars = productMapper.selectStoreProductHot(id);
        return storeNavBars;
    }

    @Override
    public List<StoreNavBar> selectStoreHotProduct(int sid, int number) {
        List<StoreNavBar> storeHotProduct = storeMapper.getStoreHotProduct(sid, number);
        return storeHotProduct;
    }

    @Override
    public List<StoreNavBar> selectStoreProductsByPage(int pageIndex,int number,int sid) {
        List<StoreNavBar> storeProductByPage = storeMapper.getStoreProductByPage((pageIndex - 1) * number, number, sid);
        return storeProductByPage;
    }
}
